package com.haoshuang.zhouzhoubang.ui.page.shop.order

import androidx.lifecycle.rxLifeScope
import com.haoshuang.zhouzhoubang.base.request
import com.haoshuang.zhouzhoubang.model.bean.WxPayBean
import com.haoshuang.zhouzhoubang.model.bean.ZfbBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class ShopOrderViewModel : BaseViewModel() {
    val getData2 = StatefulMutableLiveData<ZfbBean>()
    fun getData2(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<ZfbBean>("api/goods/continue_pay_order", *params,
                onStart = {
                    getData2.value = StateData.Loading
                },
                onError = { msg, code ->
                    getData2.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData2.value = StateData.Success(it)
                })
        }
    }
    val getData3 = StatefulMutableLiveData<WxPayBean>()
    fun getData3(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<WxPayBean>("api/goods/continue_pay_order", *params,
                onStart = {
                    getData3.value = StateData.Loading
                },
                onError = { msg, code ->
                    getData3.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData3.value = StateData.Success(it)
                })
        }
    }
}